package com.crm.base.controller;



import com.crm.base.domain.AjaxResult;
import com.crm.base.domain.LoginUser;
import com.crm.base.domain.User;
import com.crm.base.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author author
 * @since 2024-07-12
 */
@RestController
@RequestMapping("user")
public class UserController {
    @Autowired
    private IUserService userService;

    @PostMapping("login")

    public AjaxResult login(@RequestBody User user){

        return userService.login(user);


    }
    @GetMapping("info")
    public AjaxResult info(Authentication authentication){

        LoginUser loginUser = (LoginUser) authentication.getPrincipal();

        return userService.findMenuList(loginUser.getUser().getUid());


    }



}
